import cv2
import numpy as np

img1 = cv2.imread('E:\\113.jpg')
img2 = cv2.cvtColor(img1,cv2.COLOR_BGR2GRAY) #将图像转为灰度图

ret, dst = cv2.threshold(img2, 125, 255, cv2.THRESH_BINARY)

cv2.imshow('img1',img1)
cv2.imshow('img2',img2)
cv2.imshow('dst',dst)

cv2.waitKey(0)